package com.freemyleft.left.left_app.database;

import android.content.Context;


import org.greenrobot.greendao.database.Database;

/**
 * Created by FreeMyleft on 2017/12/11.
 */

public class DataBaseManager {
    private DaoSession mDaoSession=null;
    private UserProfileDao mDao=null;
    private DataBaseManager(){

    }
    public DataBaseManager init(Context context){
        initDao(context);
        return this;
    }
    private static final  class Holdel{
        private static final DataBaseManager INSTANCE=new DataBaseManager();
    }
    public static DataBaseManager getInstance(){
        return Holdel.INSTANCE;
    }
    private void initDao(Context context){
        final ReleaseOpenHelper helper=new ReleaseOpenHelper(context,"left_app_db");
            final Database db=helper.getWritableDb();
        mDaoSession=new DaoMaster(db).newSession();
        mDao=mDaoSession.getUserProfileDao();
    }
    public final UserProfileDao getDao(){
        return mDao;
    }
}
